package com.dongdong.mq;

import com.dongdong.SmsService.SmsService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Deacription TODO
 * @Author Lenovo
 * @Date 2020/12/19 18:55
 * @Version 1.0
 **/
@Component
@RocketMQMessageListener(topic = "sms_code",consumerGroup = "sms_group")
public class SmsMQ implements RocketMQListener<String> {

    @Resource
    private SmsService smsService;

    @Override
    public void onMessage(String phone) {
        try {
            smsService.sendCode(phone);
            System.out.println("消费成功");
        }catch (Exception e){
            System.out.println("消费失败");
        }
    }

}

